package com.ruoyi.web.controller.decision;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.decision.domain.ModelClassification;
import com.ruoyi.decision.service.IModelClassificationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 模型分类Controller
 * 
 * @author zbw
 * @date 2022-08-15
 */
@RestController
@RequestMapping("/decision/modelclassification")
public class ModelClassificationController extends BaseController
{
    @Autowired
    private IModelClassificationService modelClassificationService;

    /**
     * 查询模型分类列表
     */
    @PreAuthorize("@ss.hasPermi('decision:modelclassification:list')")
    @GetMapping("/list")
    public TableDataInfo list(ModelClassification modelClassification)
    {
        startPage();
        List<ModelClassification> list = modelClassificationService.selectModelClassificationList(modelClassification);
        return getDataTable(list);
    }

    /**
     * 导出模型分类列表
     */
    @PreAuthorize("@ss.hasPermi('decision:modelclassification:export')")
    @Log(title = "模型分类", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ModelClassification modelClassification)
    {
        List<ModelClassification> list = modelClassificationService.selectModelClassificationList(modelClassification);
        ExcelUtil<ModelClassification> util = new ExcelUtil<ModelClassification>(ModelClassification.class);
        util.exportExcel(response, list, "模型分类数据");
    }

    /**
     * 获取模型分类详细信息
     */
    @PreAuthorize("@ss.hasPermi('decision:modelclassification:query')")
    @GetMapping(value = "/{modelTypeId}")
    public AjaxResult getInfo(@PathVariable("modelTypeId") String modelTypeId)
    {
        return AjaxResult.success(modelClassificationService.selectModelClassificationByModelTypeId(modelTypeId));
    }

    /**
     * 新增模型分类
     */
    @PreAuthorize("@ss.hasPermi('decision:modelclassification:add')")
    @Log(title = "模型分类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ModelClassification modelClassification)
    {
        return toAjax(modelClassificationService.insertModelClassification(modelClassification));
    }

    /**
     * 修改模型分类
     */
    @PreAuthorize("@ss.hasPermi('decision:modelclassification:edit')")
    @Log(title = "模型分类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ModelClassification modelClassification)
    {
        return toAjax(modelClassificationService.updateModelClassification(modelClassification));
    }

    /**
     * 删除模型分类
     */
    @PreAuthorize("@ss.hasPermi('decision:modelclassification:remove')")
    @Log(title = "模型分类", businessType = BusinessType.DELETE)
	@DeleteMapping("/{modelTypeIds}")
    public AjaxResult remove(@PathVariable String[] modelTypeIds)
    {
        return toAjax(modelClassificationService.deleteModelClassificationByModelTypeIds(modelTypeIds));
    }
}
